import { createAttament } from "@/api/workorder/common/attachment";

/**
 * @description 附件上传业务逻辑
 */
export async function uploadAttament(fileList: any, bussKey: string, bussId: any) {
  // 附件上传
  if ( fileList.length > 0) {
    const formData = new FormData();
    fileList.forEach(file => {
      formData.append("files", file.originFileObj ? file.originFileObj : file);
      formData.append("uid", file.uid);
    });
    formData.append("bussId", bussId);
    formData.append("bussKey", bussKey);
    // 保存附件信息
    await createAttament(formData);
  }
}

/**
 * @description 附件上传业务逻辑beforeUpload 出发
 */
export async function uploadAttamentOne(file: any, bussKey: string, bussId: any) {
  // 附件上传
    const formData = new FormData();
    formData.append("files", file);
    formData.append("bussId", bussId);
    formData.append("bussKey", bussKey);
    formData.append("uid", file.uid);
    // 保存附件信息
    return await createAttament(formData);
}





